package day240607.hw;
import java.io.File;
import java.util.List;
import java.util.Properties;

public class EmailStore implements Store {
    @Override
    public void store(List<Content> contents) throws Exception{
        Properties properties = new Properties();
        File file = new File("src/config.properties");

        String email = properties.getProperty("email");
        String subject = "来自Java的提醒";

        StringBuilder test = new StringBuilder("共命中关键词" + properties.getProperty("keyword") + contents.size() + "条：\n");

        for (Content content : contents) {
            test.append(content.getTitle()).append("\n");
            test.append(content.getText()).append("\n");
            test.append(content.getUrl()).append("\n");
        }

        //发送邮件
        MyEmailUtil.send(email, subject, test.toString());
    }
}